import type { postOrPutType } from "@/constants";
import type { HasId, IList, IResult } from "@/types/common";
import { getAxios, commonAxiosJson, exportExcelAxios, deleteAxios } from "@/utils/request.js";
/* 租机（直购）订单 地址 */
const url = "/back/rent-mobile-order";
/* 租机订单：获取 租机订单信息 */
export const getRentMobileOrderInfo = <T, D>(params?: D): Promise<IResult<IList<T>>> => {
  return getAxios<IList<T>, D>(url, params);
};
/* 租机订单：获取 租机订单详情信息 */
export const getRentMobileOrderByIdInfo = <T, D extends HasId>(params: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/" + params.id, params);
};

/* 租机订单：获取 查看验机报告信息 */
export const getRentMobileReportByIdInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/get-goods-report", params);
};
/* 租机订单：新增，租机订单信息 */
export const commonRentMobileOrderInfo = <T, D>(params: D, type: postOrPutType): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url, params, type);
};

/* 租机订单：订单 订单取消 信息 */
export const putRentMobileOrderCancelInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/cancel-rent-order", params, "PUT");
};
/* 直购订单：订单 订单取消 信息 */
export const putDirectMobileOrderCancelInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/cancel-direct-order", params, "PUT");
};

/* 直购订单：订单 订单发货 信息 */
export const putMobileOrderShippingInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/order-shipping", params, "PUT");
};

/* 直购订单：订单 订单发货(修改物流公司，快递单号) 信息 */
export const putMobileOrderUpdateShippingInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/update-order-shipping", params, "PUT");
};
/* 直购订单：订单 订单确认收货 信息 */
export const putMobileOrderConfirmInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/confirm-direct-order", params, "PUT");
};
/* 直购订单：订单 申请售后 信息 */
export const putMobileApplyRefundOrderInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/apply-refund-direct-order", params, "PUT");
};
/* 直购订单：订单 同意退款 信息 */
export const putMobileOrderAgreeRefundInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/agree-refund-direct-order", params, "PUT");
};

/* 租机订单：订单 订单复制 信息 */
export const putRentMobileOrderCopyInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/clone", params, "PUT");
};
/* 租机订单：订单 订单备注 信息 */
export const putRentMobileOrderAdminNoteInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/update-admin-note", params, "PUT");
};
/* 租机订单：订单 初审通过 信息 */
export const putRentMobileOrderApprovalInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/approval-rent-order", params, "PUT");
};
/* 租机订单：订单 修改账单分期时间 信息 */
export const putRentMobileOrderUpdateBillTimeInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/update-bill-staging-time", params, "PUT");
};
/* 获取 手机品牌信息 */
export const getRentMobileCategoryInfo = <T, D>(params?: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/category", params);
};
/* 获取 手机型号信息 */
export const getRentMobileOrderGoodsInfo = <T, D>(params?: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/goods", params);
};
/* 获取 手机内存信息 */
export const getRentMobileSpecInfo = <T, D>(params?: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/spec", params);
};
/* 租机订单：订单 更新订单地址 信息 */
export const putRentMobileOrderUpdateAddressInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/update-order-address", params, "PUT");
};
/* 租机订单：上传抖音小店订单号 */
export const putDouyinStoreOrderNoInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/update-douyin-store-order-pay-status", params, "PUT");
};
/* 租机订单：订单 获取导出文件 */
export const getExportDataListFile = <D>(params: D): Promise<Blob> => {
  return exportExcelAxios<D>(url + "/export", "GET", params);
};

/* 获取 手机号信息 */
export const getRentOrderUserMobileInfo = <T, D>(params?: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/get-order-user-mobile", params);
};
/* 获取订单验机报告信息 */
export const getInpectionReportInfo = <T, D>(params?: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/get-inpection-report", params);
};
/* 保存订单验机报告 */
export const putSaveInpectionReportInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/save-inpection-report", params, "PUT");
};
/* 删除用户回执单合同 */
export const deleteOrderReceiptEsignInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return deleteAxios<T, D>(url + "/delete-order-receipt-esign", params);
};
